import React, { Component } from 'react'
import {Modal,Form, Input, Select} from 'antd'
import PropTypes from 'prop-types'


const Item = Form.Item
const { Option } = Select;

 class Firstcatorgay extends Component {
     static propTypes={
        categoryData:PropTypes.array.isRequired,
        parentId:PropTypes.string.isRequired
     }

     UNSAFE_componentWillMount(){
         this.props.setForm(this.props.form)
     }
   
    render() {
        const { getFieldDecorator } = this.props.form
        const { visible,onOk,onCancel,categoryData,parentId} = this.props
        
        return (
    <div>
        <Modal
        style={{
            width:'300px',
        }}
          title="添加分类"
          visible={visible}
          onOk={onOk}
          onCancel={onCancel}
        >
        <Form>
         <Item label="所属分类"
         >
             {
                 getFieldDecorator('parentId',{
                    initialValue:parentId
                 })(
                    <Select
 
                    > 
                       
                 {
                    categoryData && categoryData.map(v=><Option key={v._id} value={v._id}>{v.name}</Option> )
                 }   
                    </Select> 
                 )
             }
        
         </Item>
         <Item label="分类名称">
             {
                 getFieldDecorator('categoryName',{
                     initialValue:''
                 })(<Input placeholder='请输入分类名称'/>)
             }
         </Item>
         </Form>
        </Modal>
    </div>
        )
    }
}

export default  Form.create()(Firstcatorgay) 
